package com.liaoban.app.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.liaoban.app.R;
import com.liaoban.app.api.type.Rank;
import com.liaoban.app.helper.ImageHelper;
import com.liaoban.app.util.CommonUtils;

import java.util.List;

/**
 * Created by ybc on 2018/7/16 0016.
 * 排行榜
 */
public class RankChildAdapter extends BaseQuickAdapter<Rank, BaseViewHolder> {

    public RankChildAdapter(@Nullable List<Rank> data) {
        super(R.layout.item_rank_child, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Rank item) {
        helper.setText(R.id.tv_pos, "" + (helper.getLayoutPosition() + 4));
        ImageView ivSrc = helper.getView(R.id.iv_src);
        ImageHelper.load(ivSrc, CommonUtils.getFullPic(item.getWuserSrc()));
        helper.setText(R.id.tv_name, item.getName());
        helper.setText(R.id.tv_jietong, item.getJietong());
        ImageView ivGrade = helper.getView(R.id.iv_grade);
        ImageHelper.load(ivGrade, CommonUtils.getRecommendGradeRes(item.getWuserGrade()));
        switch (item.getFansIsStatus()) {
            case 0:
                helper.setGone(R.id.iv_follow, true);
                helper.setImageResource(R.id.iv_follow, R.mipmap.ic_follow_she);
                break;
            case 1:
                helper.setGone(R.id.iv_follow, true);
                helper.setImageResource(R.id.iv_follow, R.mipmap.ic_has_follow);
                break;
            case 2:
                helper.setGone(R.id.iv_follow, true);
                helper.setImageResource(R.id.iv_follow, R.mipmap.ic_fh);
                break;
            case 3:
                helper.setGone(R.id.iv_follow, false);
        }
        switch (item.getLineStatus()) {
            case 1:
                helper.setBackgroundRes(R.id.tv_line_status, R.drawable.shape_yellow_oval);
                break;
            case 2:
                helper.setBackgroundRes(R.id.tv_line_status, R.drawable.shape_gray_oval);
                break;
            case 3:
                helper.setBackgroundRes(R.id.tv_line_status, R.drawable.shape_red_oval);
                break;
        }
        helper.addOnClickListener(R.id.iv_follow);
    }
}
